using System;
using System.Collections.Generic;
using System.Text;
using Jbe.TestSuite.Infrastructure.Interface;
using Jbe.TestSuite.TestDevice.Manager;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Practices.CompositeUI.UIElements;
using Jbe.TestSuite.TestDevice.Manager.Constants;
using Microsoft.Practices.CompositeUI.Commands;
using System.Windows.Forms;
using Jbe.TestSuite.TestDevice.Manager.Tests.Mocks;

namespace Jbe.TestSuite.TestDevice.Manager.Tests
{
    public abstract class FixtureBase
    {
        protected TestableRootWorkItem rootWorkItem;
        protected MockUIElementAdapter viewMenuItemAdapter;
        protected MockWorkspace dockPanelWorkspace;

        [TestInitialize]
        public virtual void TestInitialize()
        {
            rootWorkItem = new TestableRootWorkItem();

            MockUIElementAdapterFactory uiAdapterFactory = new MockUIElementAdapterFactory();
            rootWorkItem.Services.Get<IUIElementAdapterFactoryCatalog>().RegisterFactory(uiAdapterFactory);
            viewMenuItemAdapter = new MockUIElementAdapter();
            rootWorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.ViewMenuItem, viewMenuItemAdapter);

            ICommandAdapterMapService mapService = rootWorkItem.Services.Get<ICommandAdapterMapService>();
            mapService.Register(typeof(ToolStripItem), typeof(TestableToolStripItemCommandAdapter));

            dockPanelWorkspace = new MockWorkspace();
            rootWorkItem.Workspaces.Add(dockPanelWorkspace, WorkspaceNames.DockPanelWorkspace);
        }

        [TestCleanup]
        public virtual void TestCleanup()
        {
            rootWorkItem.Dispose();
        }
    }
}
